/**
  ******************************************************************************
  * @file    Api/glcddisplay.c 
  * @author  zlf
  * @version V1.0.0
  * @date    2016-04-05
  * @brief   glcddisplay.c module
  ******************************************************************************
  */

/* Includes ------------------------------------------------------------------*/
#include <string.h>
#include "GlcdDisplay.h"
#include "Font16x8.h"
#include "Chinese16x16.h"

/* Private functions ---------------------------------------------------------*/

/**
  * @brief  This function to write an english character on glcd.
  * @param  None
  * @retval None
  */
/*
void Glcd_Write_Char( uc8 Ch, Gui_TextMode TextMode )
{
	u8 Char_Index = 0, i = 0;

	Char_Index = Ch - FONT_START_ADDRESS;

	//Write the above half of character
	switch( TextMode )
	{
		case GUI_TEXTMODE_NORMAL:
		case GUI_TEXTMODE_UNDERLINE:
			for( i = 0; i < FONT_LENGTH; i++ )
			{
				Glcd_Data_Write( Font16x8[Char_Index][i] );
			}
			break;

		case GUI_TEXTMODE_REVERSE:
			for( i = 0; i < FONT_LENGTH; i++ )
			{
				Glcd_Data_Write( Font16x8[Char_Index][i] ^ 0xFF );
			}
			break;

		default:
			break;
	}

	//Back to the original X Address before writing the below half of character, Increment Y Address
	Glcd_Set_XY_Address( Glcd_Position_Cur.LcdXAddress - FONT_LENGTH, Glcd_Position_Cur.LcdYAddress + 1 );

	//Write the below half of character
	switch( TextMode )
	{
		case GUI_TEXTMODE_NORMAL:
			for( i = 0; i < FONT_LENGTH; i++ )
			{
				Glcd_Data_Write( Font16x8[Char_Index][i+FONT_LENGTH] );
			}
			break;

		case GUI_TEXTMODE_REVERSE:
			for( i = 0; i < FONT_LENGTH; i++ )
			{
				Glcd_Data_Write( Font16x8[Char_Index][i+FONT_LENGTH] ^ 0xFF );
			}
			break;

		case GUI_TEXTMODE_UNDERLINE:
			for( i = 0; i < FONT_LENGTH; i++ )
			{
				Glcd_Data_Write( Font16x8[Char_Index][i+FONT_LENGTH] | 0x80 );
			}
			break;

		default:
			break;
	}

	//Back the original Y Address
	Glcd_Set_Y_Address( Glcd_Position_Cur.LcdYAddress - 1 );
}
*/

void Glcd_Write_Char( uc8 Ch, Gui_TextMode TextMode )
{
	u8 x_address = 0, y_address = 0;
	OLED_Get_XY_Position(&x_address, &y_address);
	OLED_ShowChar(x_address,y_address,Ch,OLED_GUI_FONTSIZE_SMALL,TextMode);
}
	

/**
  * @brief  This function to put an english string on glcd.
  * @param  pstr, the pointer of english string to be displayed.
  * @param  TextMode, the text mode of GUI.  
  * @retval None
  */
void Glcd_Put_EnStr( const char* pstr, Gui_TextMode TextMode )
{
	while( *pstr )
	{
		Glcd_Write_Char( *pstr, TextMode );
		++pstr;
	}
}

/**
  * @brief  This function to write a digit on glcd.
  * @param  Digit, digit to be displayed,
  * @param  TextMode, the text mode of GUI. 
  * @retval None
  */
void Glcd_Write_Digit( uc8 Digit, Gui_TextMode TextMode )
{
	Glcd_Write_Char( Digit+'0', TextMode );
}

/**
  * @brief  This function to write a decimal on glcd.
  * @param  Digit, digit to be displayed,
  * @param  TextMode, the text mode of GUI. 
  * @retval None
  */
void Glcd_Write_Decimal( uc8 Decimal, Gui_TextMode TextMode )
{
	if( Decimal > 99 )
	{
		Glcd_Put_EnStr( "**", TextMode );
		return;
	}
	if( Decimal > 9)
	{
		Glcd_Write_Digit( Decimal/10, TextMode );
	}
	else
	{
		Glcd_Write_Char( ' ', TextMode );
	}
	Glcd_Write_Digit( Decimal%10, TextMode );	
}

/**
  * @brief  This function to write a hundred number on glcd.
  * @param  hundred, digit to be displayed,
  * @param  TextMode, the text mode of GUI. 
  * @retval None
  */
void Glcd_Write_Hundred( uc16 hundred, Gui_TextMode TextMode )
{
	u16 hundred_Tmp = 0;

	//hundred exceed the limit, display "***" for error
	if( hundred > 999 )
	{
		Glcd_Put_EnStr( "***", TextMode );
		return;
	}

	hundred_Tmp = hundred;

	//Hundred_Tmp >= 100
	if( hundred_Tmp >= 100 )
	{
		//display the hundred digit
		Glcd_Write_Digit( hundred_Tmp/100, TextMode );
		hundred_Tmp = hundred_Tmp - hundred_Tmp/100*100;
		//display the decimal digit
		Glcd_Write_Digit( hundred_Tmp/10, TextMode );
		hundred_Tmp = hundred_Tmp - hundred_Tmp/10*10;
		//display the individual digit
		Glcd_Write_Digit( hundred_Tmp, TextMode );
	}
	else if( hundred_Tmp >= 10 )
	{
		Glcd_Write_Char( ' ', TextMode );
		//display the decimal digit
		Glcd_Write_Digit( hundred_Tmp/10, TextMode );
		hundred_Tmp = hundred_Tmp - hundred_Tmp/10*10;
		//display the individual digit
		Glcd_Write_Digit( hundred_Tmp, TextMode );
	}
	else
	{
		//No decimal digit
		Glcd_Write_Char( ' ', TextMode );
		Glcd_Write_Char( ' ', TextMode );
		//display the individual digit
		Glcd_Write_Digit( hundred_Tmp, TextMode );
	}
}

/**
  * @brief  This function to write a thousand number on glcd.
  * @param  hundred, digit to be displayed,
  * @param  TextMode, the text mode of GUI. 
  * @retval None
  */
void Glcd_Write_Thousand( uc16 thousand, Gui_TextMode TextMode )
{
	u16 Thousand_Tmp = 0;

	//hundred exceed the limit, display "***" for error
	if( thousand > 9999 )
	{
		Glcd_Put_EnStr( "****", TextMode );
		return;
	}

	Thousand_Tmp = thousand;

	//Hundred_Tmp >= 100
	if( Thousand_Tmp >= 1000 )
	{
        //display the thousand digit
		Glcd_Write_Digit( Thousand_Tmp/1000, TextMode );
		Thousand_Tmp = Thousand_Tmp - Thousand_Tmp/1000*1000;
		//display the hundred digit
		Glcd_Write_Digit( Thousand_Tmp/100, TextMode );
		Thousand_Tmp = Thousand_Tmp - Thousand_Tmp/100*100;
		//display the decimal digit
		Glcd_Write_Digit( Thousand_Tmp/10, TextMode );
		Thousand_Tmp = Thousand_Tmp%10;
		//display the individual digit
		Glcd_Write_Digit( Thousand_Tmp, TextMode );
	}
	//Hundred_Tmp < 100
	else
	{
		//No Thousand digit
		Glcd_Write_Char( ' ', TextMode );
		if( Thousand_Tmp >= 100 )
		{
			//display the hundred digit
			Glcd_Write_Digit( Thousand_Tmp/100, TextMode );
			Thousand_Tmp = Thousand_Tmp - Thousand_Tmp/100*100;
			//display the decimal digit
			Glcd_Write_Digit( Thousand_Tmp/10, TextMode );
			Thousand_Tmp = Thousand_Tmp%10;
			//display the individual digit
			Glcd_Write_Digit( Thousand_Tmp, TextMode );
		}
		else if( Thousand_Tmp >= 10 )
		{
			Glcd_Write_Char( ' ', TextMode );
			//display the decimal digit
			Glcd_Write_Digit( Thousand_Tmp/10, TextMode );
			Thousand_Tmp = Thousand_Tmp%10;
			//display the individual digit
			Glcd_Write_Digit( Thousand_Tmp, TextMode );
		}
		else
		{
			//No decimal digit
			Glcd_Write_Char( ' ', TextMode );
			Glcd_Write_Char( ' ', TextMode );
			//display the individual digit
			Glcd_Write_Digit( Thousand_Tmp, TextMode );
		}
	}
}
void Glcd_Write_Million( uc16 million, Gui_TextMode TextMode )
{
	u16 Million_Tmp = 0;

	//hundred exceed the limit, display "***" for error
	if( million > 99999 )
	{
		Glcd_Put_EnStr( "*****", TextMode );
		return;
	}

	Million_Tmp = million;
	if( Million_Tmp >= 10000 )
	{
		Glcd_Write_Digit( Million_Tmp/10000, TextMode );
		Million_Tmp = Million_Tmp - Million_Tmp/10000*10000;
        //display the thousand digit
		Glcd_Write_Digit( Million_Tmp/1000, TextMode );
		Million_Tmp = Million_Tmp - Million_Tmp/1000*1000;
		//display the hundred digit
		Glcd_Write_Digit( Million_Tmp/100, TextMode );
		Million_Tmp = Million_Tmp - Million_Tmp/100*100;
		//display the decimal digit
		Glcd_Write_Digit( Million_Tmp/10, TextMode );
		Million_Tmp = Million_Tmp%10;
		//display the individual digit
		Glcd_Write_Digit( Million_Tmp, TextMode );
	}
	else
	{	
		if( Million_Tmp >= 1000 )
		{
			Glcd_Write_Char( ' ', TextMode );
	        //display the thousand digit
			Glcd_Write_Digit( Million_Tmp/1000, TextMode );
			Million_Tmp = Million_Tmp - Million_Tmp/1000*1000;
			//display the hundred digit
			Glcd_Write_Digit( Million_Tmp/100, TextMode );
			Million_Tmp = Million_Tmp - Million_Tmp/100*100;
			//display the decimal digit
			Glcd_Write_Digit( Million_Tmp/10, TextMode );
			Million_Tmp = Million_Tmp%10;
			//display the individual digit
			Glcd_Write_Digit( Million_Tmp, TextMode );
		}
		//No Thousand digit
		else if( Million_Tmp >= 100 )
		{
			Glcd_Write_Char( ' ', TextMode );
			Glcd_Write_Char( ' ', TextMode );
			//display the hundred digit
			Glcd_Write_Digit( Million_Tmp/100, TextMode );
			Million_Tmp = Million_Tmp - Million_Tmp/100*100;
			//display the decimal digit
			Glcd_Write_Digit( Million_Tmp/10, TextMode );
			Million_Tmp = Million_Tmp%10;
			//display the individual digit
			Glcd_Write_Digit( Million_Tmp, TextMode );
		}
		else if( Million_Tmp >= 10 )
		{
			Glcd_Write_Char( ' ', TextMode );
			Glcd_Write_Char( ' ', TextMode );
			Glcd_Write_Char( ' ', TextMode );
			//display the decimal digit
			Glcd_Write_Digit( Million_Tmp/10, TextMode );
			Million_Tmp = Million_Tmp%10;
			//display the individual digit
			Glcd_Write_Digit( Million_Tmp, TextMode );
		}
		else
		{
			//No decimal digit
			Glcd_Write_Char( ' ', TextMode );
			Glcd_Write_Char( ' ', TextMode );
			Glcd_Write_Char( ' ', TextMode );
			Glcd_Write_Char( ' ', TextMode );
			//display the individual digit
			Glcd_Write_Digit( Million_Tmp, TextMode );
		}
	}
}

/**
  * @brief  This function to write a thousand number on glcd.
  * @param  hundred, digit to be displayed,
  * @param  TextMode, the text mode of GUI. 
  * @retval None
  */
void Glcd_Write_Pos( sc16 pos, Gui_TextMode TextMode )
{
	u16 pos_Tmp = 0;

	pos_Tmp = pos;
	
	Glcd_Write_Digit( pos_Tmp/10000, TextMode );
	pos_Tmp = pos_Tmp - pos_Tmp/10000*10000;
	//display the thousand digit
	Glcd_Write_Digit( pos_Tmp/1000, TextMode );
	pos_Tmp = pos_Tmp - pos_Tmp/1000*1000;
	//display the hundred digit
	Glcd_Write_Digit( pos_Tmp/100, TextMode );
	pos_Tmp = pos_Tmp - pos_Tmp/100*100;
	//display the decimal digit
	Glcd_Write_Digit( pos_Tmp/10, TextMode );
	pos_Tmp = pos_Tmp%10;
	//display the individual digit
	Glcd_Write_Digit( pos_Tmp, TextMode );
	Glcd_Write_Char( ' ', TextMode );
	
}

/**
  * @brief  This function to get the shift address of chinese on the gb16Dot.
  * @param  ChrCn, the pointer of chinese to be displayed. 
  * @retval The address of the chinese word.
  */
u8 Get_Chinese_Address(uc8* ChrCn)
{
	register u8 k;

	//Find the index of chinese char on Ack_GB16
	for( k = 0; k < sizeof(gb16Dot)/sizeof(gb16Dot[0]); k++ )
	{
		if( ( *(ChrCn) == gb16Dot[k].Unicode[0] ) &&
			( *(ChrCn+1) == gb16Dot[k].Unicode[1] ) 
		  )
			break;
	}

	//Could not find the index
	if( k >= sizeof(gb16Dot)/sizeof(gb16Dot[0]) )
	{
		return 0;
	}

	return k;
}

/**
  * @brief  This function to get the shift address of chinese on the gb16Dot.
  * @param  ChrCn, the pointer of chinese to be displayed. 
  * @retval The address of the chinese word.
  */
void Glcd_Write_Chinese( uc8* ChrCn, Gui_TextMode TextMode )
{
	register u8 i = 0, CnIndex = 0;

	//Get the shift address of chinese
	CnIndex = Get_Chinese_Address(ChrCn);

	//Write the above half of chinese
	switch( TextMode )
	{
		case GUI_TEXTMODE_NORMAL:
		case GUI_TEXTMODE_UNDERLINE:
			for( i = 0; i < CHINESE_LENGTH; i++ )
			{
				Glcd_Data_Write( gb16Dot[CnIndex].Msk[i] );
			}
			break;

		case GUI_TEXTMODE_REVERSE:
			for( i = 0; i < CHINESE_LENGTH; i++ )
			{
				Glcd_Data_Write( gb16Dot[CnIndex].Msk[i] ^ 0xFF );
			}
			break;

		default:
			break;
	}

	//Back to the original X Address and Increment Y Address
	Glcd_Set_XY_Address( Glcd_Position_Cur.LcdXAddress-CHINESE_LENGTH, Glcd_Position_Cur.LcdYAddress+1 );

	//Write the below half of chinese
	switch( TextMode )
	{
		case GUI_TEXTMODE_NORMAL:
			for( i = 0; i < CHINESE_LENGTH; i++ )
			{
				Glcd_Data_Write( gb16Dot[CnIndex].Msk[i+CHINESE_LENGTH] );
			}
			break;

		case GUI_TEXTMODE_REVERSE:
			for( i = 0; i < CHINESE_LENGTH; i++ )
			{
				Glcd_Data_Write( gb16Dot[CnIndex].Msk[i+CHINESE_LENGTH] ^ 0xFF );
			}
			break;

		case GUI_TEXTMODE_UNDERLINE:
			for( i = 0; i < CHINESE_LENGTH; i++ )
			{
				Glcd_Data_Write( gb16Dot[CnIndex].Msk[i+CHINESE_LENGTH] | 0x80 );
			}
			break;

		default:
			break;
	}

	//Back to the original X Address
	Glcd_Set_Y_Address( Glcd_Position_Cur.LcdYAddress-1 );

}

/**
  * @brief  This function to put an chinese string on glcd.
  * @param  none
  * @retval none
  */
void Glcd_Put_CnStr( const u8* pStrCn, Gui_TextMode TextMode )
{
	u8 UnicodeArray[2];

	while( *pStrCn )
	{
		//copy the unicode of chinese from string
		memcpy( UnicodeArray, pStrCn, 2 );
		Glcd_Write_Chinese( UnicodeArray, TextMode );
		pStrCn += 2;
	}
}

/**
  * @brief  This function to put an string on specific address of glcd.
  * @param  none
  * @retval none
  */
/*
void Glcd_DispStringAt(const u8* str, u8 X0, u8 Y0, u8 X1, Gui_TextMode TextMode, Gui_AlignStyle AlignStyle)
{
	u8 Len = strlen( (const char *)str ) * 8;
	u8 XOffset = 0;
	u8 UnicodeArray[2];

	//Calculate the offset on X address
	switch( AlignStyle )
	{
		case GUI_ALIGNSTYLE_LEFT:
			XOffset = 0;
			break;

		case GUI_ALIGNSTYLE_HCENTER:
			XOffset = ( (X1-X0)-Len ) / 2;
			break;

		case GUI_ALIGNSTYLE_RIGHT:
			XOffset = ( X1 - X0 - Len );
			break;

		default:
			break;
	}

	//Obtain the displaying start address
	Glcd_Set_XY_Address( X0+XOffset, Y0 );

	//Displaying the content
	while( *str )
	{
		//ASCII code
		if( *str < 0x80 )
		{
			Glcd_Write_Char( *str, TextMode );
			str++;
		}
		//Chinese code
		else
		{
			//copy the unicode of chinese from string
			memcpy( UnicodeArray, str, 2 );
			Glcd_Write_Chinese( UnicodeArray, TextMode );
			str += 2;
		}
	}
}
*/

void Glcd_DispStringAt(const u8* str, u8 X0, u8 Y0, u8 X1, Gui_TextMode TextMode, Gui_AlignStyle AlignStyle)
{
	OLED_DispStringAt(str, X0, Y0, X1, OLED_GUI_FONTSIZE_SMALL, TextMode, AlignStyle);
}

/**
  * @brief  This function to clear the line of glcd.
  * @param  none
  * @retval none
  */
/*
void Glcd_Clear_Line( u8 X0, u8 Y0, u8 X1 )
{
	u8 Column;

	//Clear the above part
	Glcd_Set_XY_Address(X0,Y0);
	for( Column = X0; Column < X1; Column++ )
	{
		Glcd_Data_Write(0x00);
	}

	//Clear the lower part
	Glcd_Set_XY_Address(X0,Y0+1);
	for( Column = X0; Column < X1; Column++ )
	{
		Glcd_Data_Write(0x00);
	}
}
*/

void Glcd_Clear_Line( u8 X0, u8 Y0, u8 X1 )
{
	OLED_Clear_Line(X0,Y0,X1,OLED_GUI_FONTSIZE_SMALL);
}


/**
  * @brief  This function to write a hundred number on glcd.
  * @param  hundred, digit to be displayed,
  * @param  TextMode, the text mode of GUI. 
  * @retval None
  */

void Glcd_Write_Kg( uc16 hundred, Gui_TextMode TextMode )
{
	u16 hundred_Tmp = 0;

	//hundred exceed the limit, display "***" for error
	if( hundred > 999 )
	{
		//Glcd_Put_EnStr( "L=***Kg", TextMode );
		return;
	}
	//Glcd_Put_EnStr( "L=", TextMode );
	hundred_Tmp = hundred;

	//Hundred_Tmp >= 100
	if( hundred_Tmp >= 100 )
	{
		//display the hundred digit
		Glcd_Write_Digit( hundred_Tmp/100, TextMode );
		hundred_Tmp = hundred_Tmp - hundred_Tmp/100*100;
		//display the decimal digit
		Glcd_Write_Digit( hundred_Tmp/10, TextMode );
		hundred_Tmp = hundred_Tmp - hundred_Tmp/10*10;
		//display the individual digit
		Glcd_Write_Digit( hundred_Tmp, TextMode );
		Glcd_Put_EnStr( "Kg", TextMode );
	}
	else if( hundred_Tmp >= 10 )
	{
		Glcd_Write_Digit( hundred_Tmp/10, TextMode );
		//display the individual digit
		Glcd_Write_Digit( hundred_Tmp%10, TextMode );
		Glcd_Put_EnStr( "Kg ", TextMode );
	}
	else
	{
		//display the individual digit
		Glcd_Write_Digit( hundred_Tmp%10, TextMode );
		Glcd_Put_EnStr( "Kg  ", TextMode );
	}
}

/**
  * @brief  This function to write a hundred number on glcd.
  * @param  hundred, digit to be displayed,
  * @param  TextMode, the text mode of GUI. 
  * @retval None
  */
void Glcd_Write_Cm( sc16 hundred, Gui_TextMode TextMode )
{
	u16 hundred_Tmp = 0;

	Glcd_Put_EnStr( "P=", TextMode );

	//hundred exceed the limit, display "***" for error
	if( hundred > 9999 )
	{
		Glcd_Put_EnStr( "*****cm", TextMode );
		return;
	}

	if( hundred < 0 )
	{
		Glcd_Write_Char( '-', TextMode );
		hundred_Tmp = -hundred;
		//Hundred_Tmp >= 1000
		if( hundred_Tmp >= 1000 )
		{
			//display the hundred digit
			Glcd_Write_Digit( hundred_Tmp/1000, TextMode );
			hundred_Tmp = hundred_Tmp - hundred_Tmp/1000*1000;		
			Glcd_Write_Digit( hundred_Tmp/100, TextMode );
			hundred_Tmp = hundred_Tmp - hundred_Tmp/100*100;
			//display the decimal digit
			Glcd_Write_Digit( hundred_Tmp/10, TextMode );
			hundred_Tmp = hundred_Tmp - hundred_Tmp/10*10;
			//display the individual digit
			Glcd_Write_Digit( hundred_Tmp, TextMode );
			Glcd_Put_EnStr( "cm", TextMode );
		}	
		else if( hundred_Tmp >= 100 )
		{
			//display the hundred digit
			Glcd_Write_Digit( hundred_Tmp/100, TextMode );
			hundred_Tmp = hundred_Tmp - hundred_Tmp/100*100;
			//display the decimal digit
			Glcd_Write_Digit( hundred_Tmp/10, TextMode );
			hundred_Tmp = hundred_Tmp - hundred_Tmp/10*10;
			//display the individual digit
			Glcd_Write_Digit( hundred_Tmp, TextMode );
			Glcd_Put_EnStr( "cm ", TextMode );
		}
		else if( hundred_Tmp >= 10 )
		{
			Glcd_Write_Digit( hundred_Tmp/10, TextMode );
			//display the individual digit
			Glcd_Write_Digit( hundred_Tmp%10, TextMode );
			Glcd_Put_EnStr( "cm  ", TextMode );
		}
		else
		{
			//display the individual digit
			Glcd_Write_Digit( hundred_Tmp%10, TextMode );
			Glcd_Put_EnStr( "cm   ", TextMode );
		}		
	}
	else
	{
		hundred_Tmp = hundred;
		if( hundred_Tmp >= 1000 )
		{
			//display the hundred digit
			Glcd_Write_Digit( hundred_Tmp/1000, TextMode );
			hundred_Tmp = hundred_Tmp - hundred_Tmp/1000*1000;		
			Glcd_Write_Digit( hundred_Tmp/100, TextMode );
			hundred_Tmp = hundred_Tmp - hundred_Tmp/100*100;
			//display the decimal digit
			Glcd_Write_Digit( hundred_Tmp/10, TextMode );
			hundred_Tmp = hundred_Tmp - hundred_Tmp/10*10;
			//display the individual digit
			Glcd_Write_Digit( hundred_Tmp, TextMode );
			Glcd_Put_EnStr( "cm ", TextMode );
		}	
		else if( hundred_Tmp >= 100 )
		{
			//display the hundred digit
			Glcd_Write_Digit( hundred_Tmp/100, TextMode );
			hundred_Tmp = hundred_Tmp - hundred_Tmp/100*100;
			//display the decimal digit
			Glcd_Write_Digit( hundred_Tmp/10, TextMode );
			hundred_Tmp = hundred_Tmp - hundred_Tmp/10*10;
			//display the individual digit
			Glcd_Write_Digit( hundred_Tmp, TextMode );
			Glcd_Put_EnStr( "cm  ", TextMode );
		}
		else if( hundred_Tmp >= 10 )
		{
			Glcd_Write_Digit( hundred_Tmp/10, TextMode );
			//display the individual digit
			Glcd_Write_Digit( hundred_Tmp%10, TextMode );
			Glcd_Put_EnStr( "cm   ", TextMode );
		}
		else
		{
			//display the individual digit
			Glcd_Write_Digit( hundred_Tmp%10, TextMode );
			Glcd_Put_EnStr( "cm    ", TextMode );
		}			
	}


}


/**
  * @brief  This function to write a hundred number on glcd.
  * @param  hundred, digit to be displayed,
  * @param  TextMode, the text mode of GUI. 
  * @retval None
  */
void Glcd_Write_V( uc16 hundred, Gui_TextMode TextMode )
{
	u16 hundred_Tmp = 0;

	//hundred exceed the limit, display "***" for error
	if( hundred > 999 )
	{
		Glcd_Put_EnStr( "V=***%", TextMode );
		return;
	}
	//Glcd_Put_EnStr( "V=", TextMode );
	hundred_Tmp = hundred;
   
	//Hundred_Tmp >= 100
	if( hundred_Tmp >= 100 )
	{
		//display the hundred digit
		Glcd_Write_Digit( hundred_Tmp/100, TextMode );
		hundred_Tmp = hundred_Tmp - hundred_Tmp/100*100;
		//display the decimal digit
		Glcd_Write_Digit( hundred_Tmp/10, TextMode );
		hundred_Tmp = hundred_Tmp - hundred_Tmp/10*10;
		//display the individual digit
		Glcd_Write_Digit( hundred_Tmp, TextMode );
		Glcd_Put_EnStr( "mm/s", TextMode );
	}
	else if( hundred_Tmp >= 10 )
	{
		Glcd_Write_Digit( hundred_Tmp/10, TextMode );
		//display the individual digit
		Glcd_Write_Digit( hundred_Tmp%10, TextMode );
		Glcd_Put_EnStr( "mm/s ", TextMode );
	}
	else
	{
		//display the individual digit
		Glcd_Write_Digit( hundred_Tmp%10, TextMode );
		Glcd_Put_EnStr( "mm/s  ", TextMode );
	}
}
void Glcd_Write_Time( uc8 Decimal )
{
	if( Decimal > 99 )
	{
		Glcd_Put_EnStr( "**", GUI_TEXTMODE_NORMAL );
		return;
	}
	if( Decimal > 9)
	{
		Glcd_Write_Digit( Decimal/10, GUI_TEXTMODE_NORMAL );
	}
	else
	{
		Glcd_Write_Char( '0', GUI_TEXTMODE_NORMAL );
	}
	Glcd_Write_Digit( Decimal%10, GUI_TEXTMODE_NORMAL );	
}
void Glcd_Write_Time_Rev( uc8 Decimal )
{
	if( Decimal > 99 )
	{
		Glcd_Put_EnStr( "**", GUI_TEXTMODE_NORMAL );
		return;
	}
	if( Decimal > 9)
	{
		Glcd_Write_Digit( Decimal/10, GUI_TEXTMODE_NORMAL );
	}
	else
	{
		Glcd_Write_Char( '0', GUI_TEXTMODE_NORMAL );
	}
	Glcd_Write_Digit( Decimal%10, GUI_TEXTMODE_REVERSE );	
}


